package com.facebook.imagepipeline.decoder;

import android.graphics.Bitmap.Config;
import com.facebook.common.internal.Closeables;
import com.facebook.common.references.CloseableReference;
import com.facebook.imageformat.GifFormatChecker;
import com.facebook.imageformat.ImageFormat;
import com.facebook.imageformat.ImageFormatChecker;
import com.facebook.imagepipeline.animated.factory.AnimatedImageFactory;
import com.facebook.imagepipeline.common.ImageDecodeOptions;
import com.facebook.imagepipeline.image.CloseableImage;
import com.facebook.imagepipeline.image.CloseableStaticBitmap;
import com.facebook.imagepipeline.image.EncodedImage;
import com.facebook.imagepipeline.image.ImmutableQualityInfo;
import com.facebook.imagepipeline.image.QualityInfo;
import com.facebook.imagepipeline.platform.PlatformDecoder;
import java.io.InputStream;

public class ImageDecoder
{
  private final AnimatedImageFactory mAnimatedImageFactory;
  private final Bitmap.Config mBitmapConfig;
  private final PlatformDecoder mPlatformDecoder;

  public ImageDecoder(AnimatedImageFactory paramAnimatedImageFactory, PlatformDecoder paramPlatformDecoder, Bitmap.Config paramConfig)
  {
    this.mAnimatedImageFactory = paramAnimatedImageFactory;
    this.mBitmapConfig = paramConfig;
    this.mPlatformDecoder = paramPlatformDecoder;
  }

  public CloseableImage decodeAnimatedWebp(EncodedImage paramEncodedImage, ImageDecodeOptions paramImageDecodeOptions)
  {
    return this.mAnimatedImageFactory.decodeWebP(paramEncodedImage, paramImageDecodeOptions, this.mBitmapConfig);
  }

  public CloseableImage decodeGif(EncodedImage paramEncodedImage, ImageDecodeOptions paramImageDecodeOptions)
  {
    InputStream localInputStream = paramEncodedImage.getInputStream();
    if (localInputStream == null)
      return null;
    try
    {
      if ((!paramImageDecodeOptions.forceStaticImage) && (this.mAnimatedImageFactory != null) && (GifFormatChecker.isAnimated(localInputStream)))
      {
        CloseableImage localCloseableImage = this.mAnimatedImageFactory.decodeGif(paramEncodedImage, paramImageDecodeOptions, this.mBitmapConfig);
        return localCloseableImage;
      }
      CloseableStaticBitmap localCloseableStaticBitmap = decodeStaticImage(paramEncodedImage);
      return localCloseableStaticBitmap;
    }
    finally
    {
      Closeables.closeQuietly(localInputStream);
    }
  }

  public CloseableImage decodeImage(EncodedImage paramEncodedImage, int paramInt, QualityInfo paramQualityInfo, ImageDecodeOptions paramImageDecodeOptions)
  {
    ImageFormat localImageFormat = paramEncodedImage.getImageFormat();
    if ((localImageFormat == null) || (localImageFormat == ImageFormat.UNKNOWN))
      localImageFormat = ImageFormatChecker.getImageFormat_WrapIOException(paramEncodedImage.getInputStream());
    switch (1.$SwitchMap$com$facebook$imageformat$ImageFormat[localImageFormat.ordinal()])
    {
    default:
      return decodeStaticImage(paramEncodedImage);
    case 1:
      throw new IllegalArgumentException("unknown image format");
    case 2:
      return decodeJpeg(paramEncodedImage, paramInt, paramQualityInfo);
    case 3:
      return decodeGif(paramEncodedImage, paramImageDecodeOptions);
    case 4:
    }
    return decodeAnimatedWebp(paramEncodedImage, paramImageDecodeOptions);
  }

  public CloseableStaticBitmap decodeJpeg(EncodedImage paramEncodedImage, int paramInt, QualityInfo paramQualityInfo)
  {
    CloseableReference localCloseableReference = this.mPlatformDecoder.decodeJPEGFromEncodedImage(paramEncodedImage, this.mBitmapConfig, paramInt);
    try
    {
      CloseableStaticBitmap localCloseableStaticBitmap = new CloseableStaticBitmap(localCloseableReference, paramQualityInfo, paramEncodedImage.getRotationAngle());
      return localCloseableStaticBitmap;
    }
    finally
    {
      localCloseableReference.close();
    }
  }

  public CloseableStaticBitmap decodeStaticImage(EncodedImage paramEncodedImage)
  {
    CloseableReference localCloseableReference = this.mPlatformDecoder.decodeFromEncodedImage(paramEncodedImage, this.mBitmapConfig);
    try
    {
      CloseableStaticBitmap localCloseableStaticBitmap = new CloseableStaticBitmap(localCloseableReference, ImmutableQualityInfo.FULL_QUALITY, paramEncodedImage.getRotationAngle());
      return localCloseableStaticBitmap;
    }
    finally
    {
      localCloseableReference.close();
    }
  }
}

/* Location:           C:\Users\user\Desktop\dd28_pcdd720\classes_dex2jar.jar
 * Qualified Name:     com.facebook.imagepipeline.decoder.ImageDecoder
 * JD-Core Version:    0.6.2
 */